﻿using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace FEShop.AppUserService.Models
{
    /// <summary>
    /// 购物车商品项
    /// </summary>
    [SugarTable("shop_cart_item")]
    public class ShopCartItem
    {
        /// <summary>
        /// Id
        /// </summary>
        [Key]
        public Guid Id { get; set; }
        /// <summary>
        /// 购物车Id
        /// </summary>
        [Required]
        public Guid ShopCartId { get; set; }
        /// <summary>
        /// 商品Id
        /// </summary>
        [Required]
        public Guid ProductId { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string ProductName { get; set; }
        /// <summary>
        /// 商品数量
        /// </summary>
        [Range(1, 1000)]
        public int Quantity { get; set; } = 1;
        /// <summary>
        /// 商品价格
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal UnitPrice { get; set; }
        /// <summary>
        /// 加入时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        // 导航属性
        [ForeignKey(nameof(ShopCartId))]
        public virtual ShopCart ShopCart { get; set; } = null!;
    }
}
